package com.ctshk.rpc.order.localfun.generator;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Random;

public class LocalFunOrderGenerator {


    /**牌照号码*/
    public static String LICENSE_NO ="test_def";
    /**咨询电话*/
    public static String SUPPORT_NO ="test_def";

    /**
     * 获取订单销售单号
     * 规则 A+部門代碼+員工編號+年後2位+月日4位+4位隨機數字
     * @return
     */
    public static String getOrderNumer(String depCode, String empNumer) {
        StringBuffer orderNumber = new StringBuffer();
        orderNumber.append("W");
        orderNumber.append(depCode);
        orderNumber.append(empNumer);
        String year = LocalDate.now().format(DateTimeFormatter.ofPattern("yy"));
        orderNumber.append(year);
        String month = LocalDate.now().format(DateTimeFormatter.ofPattern("MMdd"));
        orderNumber.append(month);
        String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("HHmm"));
        orderNumber.append(time);
        return orderNumber.toString();
    }

    public static String getVisitorOrderNumer() {
        StringBuffer orderNumber = new StringBuffer();
        orderNumber.append("W");
        String year = LocalDate.now().format(DateTimeFormatter.ofPattern("yy"));
        orderNumber.append(year);
        String month = LocalDate.now().format(DateTimeFormatter.ofPattern("MMdd"));
        orderNumber.append(month);
        String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("HHmm"));
        orderNumber.append(time);
        return orderNumber.toString();
    }

    /**
     * 获取订单收款单号
     *规则 SKD+年後2位+月日4位+時分秒6位+2位隨機數字
     * @return String
     */
    public static String getCollectionNumber() {
        StringBuffer collectionNumber = new StringBuffer();
        collectionNumber.append("SKD");
        String year = LocalDate.now().format(DateTimeFormatter.ofPattern("yy"));
        collectionNumber.append(year);
        String month = LocalDate.now().format(DateTimeFormatter.ofPattern("MMdd"));
        collectionNumber.append(month);
        String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("HHmmss"));
        collectionNumber.append(time);
        Random random = new Random();
        int number = random.nextInt(90) + 10;
        collectionNumber.append(number+"");
        return collectionNumber.toString();
    }
    /**
     * 获取订单退款单号
     *规则 SKD+年後2位+月日4位+時分秒6位+2位隨機數字
     * @return String
     */
    public static String getRefundNumber() {
        StringBuffer refund = new StringBuffer();
        refund.append("TKD");
        String year = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yy"));
        refund.append(year);
        String month = LocalDateTime.now().format(DateTimeFormatter.ofPattern("MMdd"));
        refund.append(month);
        String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("HHmmss"));
        refund.append(time);
        Random random = new Random();
        int number = random.nextInt(90) + 10;
        refund.append(number+"");
        return refund.toString();
    }
    /**
     * 获取收据编号
     * 规则: 門市編號+員工編號+年後2位+月日4位+A+時分秒6位+（S）
     * @return
     */
    public static String getReceiptNumer(String depCode, String empNumer){
        StringBuffer receiptNumer = new StringBuffer();
        receiptNumer.append(depCode);
        receiptNumer.append(empNumer);
        String year = LocalDate.now().format(DateTimeFormatter.ofPattern("yy"));
        receiptNumer.append(year);
        String month = LocalDate.now().format(DateTimeFormatter.ofPattern("MMdd"));
        receiptNumer.append(month);
        receiptNumer.append("A");
        String time = LocalDate.now().format(DateTimeFormatter.ofPattern("HHmmss"));
        receiptNumer.append(time);
        receiptNumer.append("(s)");
        return receiptNumer.toString();
    }


}
